<?php
define('FPDF_FONTPATH', 'font/');
require('./font/fpdf.php');
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
  $pdf=new FPDF('P','mm','A4');   //Create new pdf file
  $pdf->Open();     //Open file
  $pdf->SetAutoPageBreak(false);  //Disable automatic page break
  $pdf->AddPage();  //Add first page

  $i         = 0; 
  $rowHeight = 6;
  $yAxis     = 19;

  $yAxis = $yAxis + $rowHeight;
  
  pageHeader();
  pageContain();
  pageFooterlast();
  
//  $srNo = 0;
//  $orderId       = isset($_REQUEST['orderId']) ? $_REQUEST['orderId']   : 0;
//  $tableId       = isset($_REQUEST['tableId']) ? $_REQUEST['tableId']   : 0;
//  $waiterId      = isset($_REQUEST['waiterId']) ? $_REQUEST['waiterId'] : 0;
//  $tablePart     = isset($_REQUEST['tablePart']) ? $_REQUEST['tablePart'] : 0;
//  $totalAmount   = 0;
//  $totalQuantity = 0;
//  $srNo = 0;
//  $selectOrder = "SELECT itemName,quantity,orderTime,ordereditems.orderId,
//                         waiterName,ordermaster.tableId,ordereditems.itemId,waiter.waiterId,ordermaster.tableId,
//                         item.itemPrice
//                    FROM ordereditems 
//               LEFT JOIN ordermaster ON ordereditems.orderId = ordermaster.orderId
//               LEFT JOIN item ON ordereditems.itemId = item.itemId
//               LEFT JOIN waiter ON ordermaster.waiterId = waiter.waiterId
//                   WHERE ordermaster.tableId = ".$tableId."
//                     AND ordermaster.waiterId = ".$waiterId."
//                     AND ordermaster.orderstatus = 'L'
//                     AND ordermaster.tablePart = '".$tablePart."'";
//  $selectOrderRes = mysql_query($selectOrder);  
//  while($orderRow = mysql_fetch_array($selectOrderRes))
//  {
//  	$srNo++;
//    $itemName       = $orderRow['itemName'];
//    $itemPrice      = $orderRow['itemPrice'];
//    $quantity       = $orderRow['quantity'];
//    $waiterName     = $orderRow['waiterName'];
//    $amount         = $orderRow['quantity'] * $orderRow['itemPrice'];
//    
//    $totalQuantity += $orderRow['quantity'];
//    $totalAmount   += $amount;
//    $i++;
    
    
    
    
    
    
  }
  
//    $pdf->SetTextColor(0,0,0);
//    $pdf->SetXY(60,18);
//    $pdf->SetFont('Arial', 'B', 15);
//    $pdf->Cell(12, 1, 0,   0,0,'C');
    
//    $pdf->SetXY(60,18);
//    $pdf->SetFont('Arial', 'B', 15);
//    $pdf->Cell(65, 2, 0,   0,0,'C');
//    
//    $pdf->SetTextColor(255,0,0);
//    $pdf->SetFont('Arial', 'B', 10);
//    $pdf->SetXY(5,117);
//    $pdf->Cell(12, 6, 'TOTAL', 1, 0, 'C', 0);
//    $pdf->Cell(15, 6, 0, 1, 0, 'C', 0);
//    $pdf->Cell(51, 6, '', 1, 0, 'C', 0);
//    $pdf->Cell(22, 6, 0, 1, 0, 'C', 0);
    //Set Row Height
    //Create file
    $pdf->Output();
//}

//header part start
function pageHeader()
{
  global $pdf;
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Times','',35);
  $pdf->SetXY(5,5);
  $pdf->Cell(200, 290, '', 1, 0, 'C');
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 20);
  $pdf->SetXY(5,9);
  $pdf->Cell(200, 7, 'Annexure - 109 (VI) Subsidiary Challan', 0, 0, 'C', 0);
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 10);
  $pdf->SetXY(5,16);
  $pdf->Cell(200,5, 'For Movement Of Goods From Processors To Manufacture / Another Procesor In Piecement Under', 0, 0, 'C', 0);
  $pdf->SetXY(5,20);
  $pdf->Cell(200,5, 'Notification No.214/86 CE Dt : 25-03-86 And Or Under Rule -4(5) Of CENVAT Credit Rule-2004', 0, 0, 'C', 0);
  $pdf->Line(5,27,205,27);
}

function pageContain()
{
  global $pdf;
  
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 12);
  $pdf->SetXY(5,24);
  $pdf->Cell(80, 13, 'A. Name And Address Of Processor :', 0, 0, 'L', 0);
  $pdf->Image('./images/job.png',6,34,70,5);
  
  $pdf->SetTextColor(230,0,0);
  $pdf->SetFont('Arial', 'B', 15);
  $pdf->SetXY(5,42);
  $pdf->Cell(85,5, 'Shakti Heat-Treaters & Engineers', 0, 0, 'L', 0);
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 12);
  $pdf->SetXY(5,48);
  $pdf->Cell(85, 5, 'Sr. No. 163/1 - p, Plot No. 3,', 0, 0, 'C', 0);
  $pdf->SetXY(5,53);
  $pdf->Cell(85, 5, 'Opp Bansi Forge. S.I.D.C. Road,', 0, 0, 'C', 0);
  $pdf->SetXY(5,58);
  $pdf->Cell(85, 5, 'VERAVAl (SHAPAR).', 0, 0, 'C', 0);
  $pdf->SetXY(5,63);
  $pdf->Cell(85, 5, 'Ta.Kotda Sangani, Dist : Rajkot.', 0, 0, 'C', 0);
  
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 12);
  $pdf->SetXY(5,70);
  $pdf->Cell(123, 18, 'B. Name And Address Of Manufacturer/ Another Processor :', 0, 0, 'L', 0);
  $pdf->Image('./images/job1.png',7,82,70,5);
  
  $pdf->Line(10,94,200,94);
  $pdf->Line(10,103,200,103);
  $pdf->Line(10,112,200,112);
  $pdf->Line(10,121,200,121);
  
  $pdf->Image('./images/job2.png',8,125,120,5);
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 12);
  $pdf->SetXY(25,92);
  $pdf->Cell(25, 90, '1. Main Challan No. :', 0, 0, 'R', 0);
  $pdf->SetXY(51,132);
  $pdf->Cell(65, 10, '', 1, 0, 'R', 0);
  
  $pdf->SetXY(72,132);
  $pdf->Cell(72, 10, 'Date :', 0, 0, 'R', 0);
  $pdf->SetXY(145,132);
  $pdf->Cell(55, 10, '', 1, 0, 'R', 0);
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 12);
  $pdf->SetXY(65,100);
  $pdf->Cell(65, 95, '2. Quantity Despatched (In Item Of Nos./ length/Weight etc.):', 0, 0, 'R', 0);
  $pdf->Image('./images/job3.png',12,151,50,5);
  
  $pdf->Line(10,165,200,165);
  $pdf->Line(10,174,200,174);
  $pdf->Line(10,183,200,183);
  $pdf->Line(10,192,200,192);
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 12);
  $pdf->SetXY(35,130);
  $pdf->Cell(38, 135, '3. Nature Of Processing Done :', 0, 0, 'R', 0);
  
  $pdf->Image('./images/job4.png',13,203,30,5);
  $pdf->Line(43,208,200,208);
  $pdf->Line(10,217,200,217);
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 12);
  $pdf->SetXY(32,150);
  $pdf->Cell(32, 150, '4.Quantity Left In Balance:', 0, 0, 'R', 0);
  $pdf->Image('./images/job5.png',64,222,30,5);
  
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 12);
  $pdf->SetXY(45,155);
  $pdf->Cell(45, 150, '(In Terms Of Nos./ Length/Weight etc.):', 0, 0, 'R', 0);
  $pdf->Line(10,239,120,239);
  $pdf->Line(10,248,120,248);
  $pdf->Line(10,257,120,257);
  
}



function pageFooterlast()
{
  global $pdf;
  $pdf->SetTextColor(0,0,0);
  $pdf->SetFont('Arial', 'B', 12);
  $pdf->SetXY(8,175);
  $pdf->Cell(1,185, 'Palace :', 0, 0, 'L', 0);
  $pdf->Image('./images/job6.png',7,270,22,3);
  
  $pdf->SetXY(8,179);
  $pdf->Cell(1,210, 'Date :', 0, 0, 'L', 0);
  $pdf->Image('./images/job7.png',7,288,22,4);
  
  $pdf->SetXY(152,187);
  $pdf->Cell(45,190, 'Signature Processor', 0, 0, 'L', 0);
  $pdf->Image('./images/job8.png',160,285,30,8);
  
  
}

?>